Liquidation protects the protocol from bad debt when a position no longer has enough equity to cover its risk. If your equity falls below a safety threshold, the engine will close your position to restore solvency. It is important to note that all collateral is lost in liquidation, therefore it is vital to regularly check your PnL in order to keep your position healthy in the case of market volatility (increasing collateral if necessary).
Liquidation threshold
Within Zenex, the health of a position is evaluated through a so-called 'maintenance margin'. A position becomes eligible for liquidation when:
Equity<maintenanceMargin
Where:
Equity=Collateral+PnL−Fees
maintenanceMargin=notionalSize×maintenanceMarginRate
Liquidation price
The liquidation price is calculated slightly differently for shorts and longs, as is shown below:
liquidationPriceLong<openPrice+openPrice×notionalSizemaintenanceMargin+feeBuffer−collateral
liquidationPriceShort>openPrice−openPrice×notionalSizemaintenanceMargin+feeBuffer−collateral